<?php
/**
  * tframe
  *
  *
  * @copyright Copyright (c) 2012 - 2014, huxiaomin
  * @author huxiaomin    2012-6-10  
  * @since		Version 1.0
  *
  */

class ALogApp{

	function hook($api){
		if ($api == 'delLog') {
			return array('ajax'=>1);
		}
	}
	
	/**
	 * 显示log管理页面
	 * @param $request
	 */
    function index($request){
        $files = glob(TLOG_DIR.'*');
        foreach ((array)$files as $key=>$v){
            $name = basename($v);
            $files[$key] = stat($v);
            $files[$key]['name'] = $name;
            $files[$key]['update_time'] = date('Y-m-d H:i:s', $files[$key]['mtime']);
        }
        return array('files'=>$files);
    }
    
    /**
     * 显示文件log内容
     * @param $request
     */
    function showLog($request){
        $name = trim($request['name']);
        $content = file_get_contents(TLOG_DIR.$name);
        return array('content'=> json_encode(array('data'=>$content)));
    }
    
    /**
     * 删除日志
     * @param $request
     */
    function delLog($request){
        $name = trim($request['name']);
        $unlink = unlink(TLOG_DIR.$name);
        return goutJson($unlink);
    }
}